import {createAsyncThunk, createSlice } from  "@reduxjs/toolkit"
import {getMovieRequest} from "../api/getMovieRequest"

export const getMovieAction =createAsyncThunk("movie/getMovieList",async()=>{
    const re = await getMovieRequest()
    
    return re.data.data.list
})


export const movieSlice = createSlice({
    name:"movie",
    initialState:{
        movieList:[]
    },
    reducers:{
        
    },
    extraReducers: {
        [getMovieAction.fulfilled](state, {
          payload
        }) {
          console.log(payload);
          state.movieList = payload
        },
        [getMovieAction.rejected](state, err) {
          console.log(err);
        },
        [getMovieAction.pending](state) {
          console.log("进行中");
        }
      },

})



export default movieSlice.reducer